//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Resource Application Block
//===============================================================================

using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using EntLibContrib.Common.Configuration;
using EntLibContrib.Resource.Configuration;
using EntLibContrib.Resource.Managers;

namespace EntLibContrib.Resource.Providers
{
	/// <summary>
	/// Xml Resource Provider.
	/// </summary>
	/// <remarks>
	/// This provider loads a binary resource file and generates a <see cref="ExtendedComponentResourceManager" /> populated
	/// with resources from the binary file.
	/// </remarks>
	[ConfigurationElementType(typeof(XmlResourceProviderData))]
	public class XmlResourceProvider : FileResourceProvider
	{
		#region Construction
		/// <summary>
		/// Initializes a new default instance of the <see cref="XmlResourceProvider"/> class.
		/// </summary>
		/// <param name="resourcePathName">Name of the resource path.</param>
		/// <param name="resourceBaseName">Name of the resource base.</param>
		public XmlResourceProvider(string resourcePathName, string resourceBaseName)
			: base(resourcePathName, resourceBaseName)
		{
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Creates the file resource manager.
		/// </summary>
		/// <param name="pathName">file path name</param>
		/// <param name="baseName">file base name</param>
		/// <returns>
		/// instance of the file resource manager type
		/// </returns>
		protected override ExtendedComponentResourceManager CreateFileResourceManager(string pathName, string baseName)
		{
			return new XmlResourceManager(pathName, baseName);
		}

		/// <summary>
		/// Gets the file resource extension.
		/// </summary>
		/// <returns>extension without the separator</returns>
		protected override string FindFileResourceExtension()
		{
			return CommonSettings.XmlExtension;
		}
		#endregion
	}
}
